package com.proposition.support.utils;
import com.proposition.commons.enums.PaperPattern;

import java.util.UUID;

/**
 * @author Administrator
 *
 */
public class UUIDUtil {
	public static void main(String[] args) {
		System.out.println(getExamUUIDByCategory("12"));
	}

	private static Sequence sequence = new Sequence(0,0);

	public static String getUUID(){
		String uuid = UUID.randomUUID().toString().replaceAll("-", "");
		return uuid;
	}

	/**
	 * 根据试题分类生成试题ID
	 * @param examCategory
	 * @return
	 */
	public static String getExamUUIDByCategory(String examCategory){
		if(examCategory == null||examCategory.isEmpty()){
			throw new NullPointerException("传入试题分类不能为空");
		}
		StringBuilder stringBuilder = new StringBuilder(examCategory);
		stringBuilder.append(sequence.nextId());
		return stringBuilder.toString();
	}

	/**
	 * 获取试卷ID
	 * @param category 试卷类型枚举
	 * @return
	 */
	public static String getPaperUUID(PaperPattern category){
		StringBuilder stringBuilder = new StringBuilder(category.getValue().toString());
		stringBuilder.append(sequence.nextId());
		return stringBuilder.toString();
	}
}
